<div id="sale-container" class="container" myapp="SALE_CUSTOM_PRODUCT">
  <%= hidden_field_tag :authenticity_token, form_authenticity_token, id: 'js-sale-custom-product-index' %>
  <div class="">
    <%= search_form_for @q, url: sales_custom_products_path, class: 'form-inline' do |f|%>
      <input type="hidden" name="store_id" value="<%= @normal_store_id%>">
      <div class="form-group js-custom-product-form-group" style="margin-left: 10px;">
        <input type="text" value="<%= @name %>" name="q[name_cont]" style="" class="form-control input"  placeholder="请输入商品名称查询">
      </div>
      <button type="submit" style="height:30px;width:40px;" class="ui-btn ui-btn-primary js-filter-custom-product">查询</button>
    <% end %>

  </div>


  <div class="app">
     <div class="app-inner clearfix">
         <table id="wechat_table" class="ui-table ui-table-list">
          <thead>
              <tr>
                <th>
                  #
                </th>
                <th>
                  <%= "名字" %>
                </th>
                <th>
                  <%= "规格" %>
                </th>
                <th>
                  <%= "价格" %>
                </th>
                <th>

                </th>
                <th>
                  <%= "操作" %>
                </th>
                <th>

                </th>
              </tr>
          </thead>
          <tbody>
              <% @products.each_with_index do |product, i| %>
                <tr>
                  <td>
                    <%= i + 1 %>
                  </td>
                  <td>
                    <%= link_to product.name, "javascript:;", class: "js-my-product-to-show", data: {id: product.id} %>
                  </td>
                  <td>
                    <%= product.format %>
                  </td>
                  <td>
                    <%= product.price %>
                  </td>
                  <td>
                    <%= link_to '删除', "javascript:;", method: :put, data: {id: product.id}, class: "js-to-remove-my-product"%>
                  </td>
                  <td>
                    <%= link_to '编辑', '#', class: 'js-to-edit-my-custom', data: {id: product.id} %>
                  </td>
                  <td>
                    <%= link_to '加入购物车', '#', class: 'js-add-my-custom-to-items', data: {id: product.id} %>
                  </td>
                </tr>
              <% end %>
          </tbody>
        </table>
      </div>
  </div>

</div>

<script type="text/javascript">
  $("a.js-my-product-to-show").on("click", function(e){
    e.preventDefault();
    var id = $(this).data("id");
    var storeId = getUrlParam("store_id");
    location.href="/sales/custom_products/"+ id +"?store_id="+storeId
  })
</script>
